<cfcomponent>

<cffunction name="rsvp" access="remote">
	<cfargument name="eventId" type="numeric" required="Yes" />
	<cfquery name="rsvp" datasource="#application.datasource#">
		EXEC rsvp #arguments.eventId#, #session.member.id#;
	</cfquery>
</cffunction>

<cffunction name="setEvent" access="remote">
	<cfargument name="event" type="struct" required="Yes" />
	<cfargument name="dummy" type="string" required="No" />
	<cfquery name="setEvent" datasource="#application.datasource#">
		EXEC setEvent <cfif isDefined("arguments.event.id")>#arguments.event.id#<cfelse>NULL</cfif>, '#arguments.event.title#', '#arguments.event.description#', #arguments.event.startDate#, #arguments.event.endDate#;
	</cfquery>
</cffunction>

<cffunction name="getEvents" access="remote">
	<cfquery name="getEvents" datasource="#application.datasource#">
		EXEC getEvents #session.member.id#;
	</cfquery>
	<cfset events = arrayNew(1) />
	<cfloop from="1" to="#getEvents.recordCount#" index="i">
		<cfset events[i] = structNew() />
		<cfset events[i].id = getEvents.eventId[i] />
		<cfset events[i].title = getEvents.title[i] />
		<cfset events[i].description = getEvents.description[i] />
		<cfset events[i].startDate = getEvents.startDate[i] />
		<cfset events[i].endDate = getEvents.endDate[i] />
        <cfset events[i].isRSVPed = getEvents.isRSVPed[i] />
	</cfloop>
	<cfreturn events />
</cffunction>

</cfcomponent>